<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller {

	var $data;

	public function __construct(){
		parent::__construct();

		$this->load->model('account');

		if(!$this->account->validate_cookie()){
			$this->session->set_flashdata('error', 'Anda tidak mempunyai akses ke halaman ini');
			header('location: '.site_url().'/login');
		}else{

			$this->data['cookie'] = $this->account->get_cookie();
		}
	}

	public function index(){

		$this->data['page']  = 'home';
		$this->data['title'] = 'Dashboard';
		$this->load->view('dashboard', $this->data);

	}

	public function profile(){
		$id->$this->data['cookie']['c_id'];

		$this->data['profile'] = $this->account->get_admin($id);
		$this->data['page']  = 'Profile';
		$this->data['title'] = 'Edit Profile';
		$this->load->view('dashboard', $this->data);
	}

	public function logout(){

		$this->account->do_logout();
		header('location: '.site_url().'/login');
	}

	public function kategori(){
		$this->load->model('kategori');
		$this->data['kategori'] = $this->kategori->get_kategori();
		$this->data['page'] = 'kategori';
		$this->data['title'] = 'Kategori resep';
		$this->load->view('dashboard', $this->data);
	}

	public function makanan(){
		$this->load->model('makanan');
		$this->data['makanan'] = $this->makanan->get_makanan();
		$this->data['page'] = 'makanan';
		$this->data['title'] = 'Daftar Makanan';
		$this->load->view('dashboard', $this->data);
	}

	public function minuman(){
		$this->load->model('minuman');
		$this->data['minuman'] = $this->minuman->get_minuman();
		$this->data['page'] = 'minuman';
		$this->data['title'] = 'Daftar Minuman';
		$this->load->view('dashboard', $this->data);
	}

	public function gambar(){
		$this->load->model('gambar');
		$this->data['gambar'] = $this->gambar->get_gambar();
		$this->data['page'] = 'gambar';
		$this->data['title'] = 'Daftar gambar';
		$this->load->view('dashboard', $this->data);
	}
	
	public function tambah(){
		$this->data['title'] = 'tambah';
		$this->data['page'] = 'tambah';
		$this->load->view('dashboard', $this->data);
	}
	
}		